<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 <%String flag="";%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
		<meta charset="utf-8">
		<title>用户注册</title>
		<link rel="stylesheet" href="css/reset.css">
		<link rel="stylesheet" href="css/main.css">
		<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/placeholder.js"></script>
		<script type="text/javascript" src="js/validate/jquery.validate.js"></script>
		<script type="text/javascript" src="js/validate/messages_cn.js"></script>
	</head>
  <script>
	//验证用户名
	function ajxValueuser(){

		var user=document.getElementById("username").value;
		var xmlhttp=null;
					if (window.XMLHttpRequest){
						xmlhttp=new XMLHttpRequest();
					}else{
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.open("GET","<%=basePath%>register.html?option=valueuser&user="+user,false);
		xmlhttp.send();
		var data=xmlhttp.responseText;  //获取返回的信息
		var json=JSON.parse(data); 
			document.getElementById("user").innerHTML=json.msg;
       if(json.flag==true){
       <%flag="true";%>
      
       alert(<%=flag%>);
       }
        
	}
	
	
	
	
	
	function valueps(){
	var password=document.getElementById("password").value;
		var xmlhttp=null;
					if (window.XMLHttpRequest){
						xmlhttp=new XMLHttpRequest();
					}else{
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.open("GET","<%=basePath%>register.html?option=valuepass&password="+password,false);
		xmlhttp.send();
		var data=xmlhttp.responseText;  //获取返回的信息
		var json=JSON.parse(data);         //解析json
			document.getElementById("span_password").innerHTML=json.msg;
	
	}
	
	//验证密码一致性
	function valuePass(){
	var confirm_password=document.getElementById("confirm_password").value;
	var password=document.getElementById("password").value;
	var xmlhttp=null;
					if (window.XMLHttpRequest){
						xmlhttp=new XMLHttpRequest();
					}else{
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.open("GET","<%=basePath%>register.html?option=valuepassword&password="+password+"&confirm="+confirm_password,false);
		xmlhttp.send();
		var data=xmlhttp.responseText;  //获取返回的信息
		var json=JSON.parse(data);         //解析json
			document.getElementById("span_confirm").innerHTML=json.msg;
	}
	
	
</script>
 <body>
		<div class="headerBar">
			<div class="topBar">
				<div class="commonWidth">
					<div class="fl">
						<a href="#" class="collection">收藏悦动商城</a>
					</div>
					<div class="fr">
						欢迎来到悦动商城！<a href="login.html">[登录]</a><a href="register.html">[免费注册]</a>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
			<div class="logoBar">
				<div class="commonWidth clearfix">
					<div class="newWidth">
						<div class="logo fl">
							<a href="index.html">
								<img src="img/logo1.jpg" alt="悦动商城">
							</a>
						</div>
						<div class="welcome_text fl">欢迎注册</div>
						<div class="clearfix"></div>
					</div>
				</div>
			</div>
		</div>
		<div class="hr_15"></div>
		<div class="commonWidth login clearfix">
			<div class="login_box">
				<form action="register.html?option=register&userflag=<%=flag %>" method="post" id="register_form" class="login_form register_form clearfix">
					<p>
						<label class="r_title" for="username"><em class="mandatory">*</em>账户名：</label>
						<input type="text" placeholder="邮箱、用户名、手机号" onkeyup="ajxValueuser() " required="required"  class="r_input username error" id="username"  name="username">
						<span class="error_message"><span for="username" generated="true" id="user" class="error">请输入用户名</span></span>
					</p>
					<p>
						<label class="r_title" for="password"><em class="mandatory">*</em>请设置密码：</label>
						<input type="password" class="r_input password error" onkeyup="valueps()" required="required"  id="password" name="password">
						<span class="error_message"><span for="password" generated="true" id="span_password" class="error">请输入密码</span></span>
					</p>

					<p>
						<label class="r_title" for="confirm_password"><em class="mandatory">*</em>请确认密码：</label>
						<input type="password" class="r_input password error" onkeyup="valuePass()" required="required"  id="confirm_password" name="confirm_password">
						<span class="error_message"><span for="confirm_password" generated="true" id="span_confirm" class="error">请输入密码</span></span>
					</p>

					<p>
						<label class="r_title" for="email"><em class="mandatory">*</em>邮箱：</label>
						<input type="email" class="r_input password error" required="required"  id="email" name="email">
						<span class="error_message"><span for="email" generated="true" class="error">请输入一个正确的邮箱</span></span>
					</p>

					<p>
						<label class="r_title" for="address"><em class="mandatory">*</em>地址：</label>
						<input type="text" class="r_input password error" required="required"  id="address" name="address">
						<span class="error_message"><span for="address" generated="true" class="error">必选字段</span></span>
					</p>
					<p>
						<label class="r_title" for="address"><em class="mandatory">*</em>电话：</label>
						<input type="text" class="r_input password error" required="required"  id="phone" name="phone">
						<span class="error_message"><span for="address" generated="true" class="error">必选字段</span></span>
					</p>	
						<input type="radio" value="男"  required="required"  id="sex" name="sex" >
						<label for="sex">男</label>
					
					
						<input type="radio" value="女"  required="required"  id="sex" name="sex" >
						<label for="sex">女</label>
					<br/>
					<p class="agree">
						<input type="checkbox" value="true"  required="required"  id="agree" name="agree" class="error">
						<label for="agree">我已阅读并同意<a href="#" class="userBook">《用户注册协议》</a></label>
						<span class="error_message"><span for="agree" generated="true" class="error">请接受我们的声明</span></span>
					</p>

					<div class="login_user">
						<input type="submit" value="注册" class="login_btn register_btn">
					</div>
				</form>
			</div>
		</div>
		<div class="copyright">
			<div class="commonWidth">
				<div class="copyright_text">
					<ul>
						<li><a href="#">悦动商城简介</a></li>|
						<li><a href="#">招纳贤士</a></li>|
						<li><a href="#">联系我们</a></li>|
						<li><a href="#">客服热线：400-675-1234</a></li>
					</ul>
					<div class="copyright_tips">
						<p>Copyright © 2006 - 2014 悦动商城版权所有 京ICP备09037834号 京ICP证B1034-8373号 某市公安局XX分局备案编号：123456789123</p>
					</div>
				</div>
				<div class="copyright_img">
					<img src="img/6_32.jpg">
					<img src="img/6_32.jpg">
					<img src="img/6_32.jpg">
					<img src="img/6_32.jpg">
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
	
	

</body>
</html>
